﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using PlaneWar.Controls;

namespace PlaneWar.Helper
{
    public class Bullet_Helper : INotifyPropertyChanged
    {
        private Control_Bullet view;
        public Bullet_Helper(double x, double y, bool isdead, Control_Bullet view)
        {
            this.Top = y;   //y轴
            this.Left = x;   //X轴
            this.view = view;   //页面
            view.DataContext = this;
            isDead = isdead;   //
        }
        public bool isDead;

        private double top;
        public double Top
        {
            get { return top; }
            set { top = value; OnPropertyChanged("Top"); }
        }

        private double left;
        public double Left
        {
            get { return left; }
            set { left = value; OnPropertyChanged("Left"); }
        }

        private double width;
        public double Width_
        {
            get { return width; }
            set { width = value; OnPropertyChanged("Width_"); }
        }

        private double height;
        public double Height_
        {
            get { return height; }
            set { height = value; OnPropertyChanged("Height_"); }
        }


        private System.Windows.Visibility vis;

        public System.Windows.Visibility Vis
        {
            get { return vis; }
            set { vis = value; OnPropertyChanged("Vis"); }
        }


        public void run()
        {
            if (this.top <= -11)
            {
                this.isDead = true;
                this.Vis = System.Windows.Visibility.Collapsed;
                return;
            }
            this.Top -= 10;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string arg)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(arg));
            }
        }
    }
}
